package componentes;


import excessoes.clienteException.ExecutarComandoLinuxException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/**
 *
 * @author Wagner Tavares
 */
public abstract class Linux {
    public static final String pathConf = "/etc/auth", pathProg = "/bin/util/auth" , pathLog = "/var/log/auth" ;
    
    public synchronized static ArrayList <String> executa(String cmd) throws excessoes.clienteException.ExecutarComandoLinuxException{
        ArrayList<String> retorno = new ArrayList<String>();
        try{
            Process proc = Runtime.getRuntime().exec(cmd);
            BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
            String line;        
            while ((line = in.readLine()) != null) {   
                retorno.add(line);   
            }
        }catch(IOException e){
            throw new ExecutarComandoLinuxException("Ocorreu um erro quando Autenticacao tentava executar um comando no linux","Linux","executa()",cmd,null);
        }
        return retorno;
    }
}
